﻿using System;
using System.Collections.Generic;
using System.Web;
using OctoOS;

/// <summary>
/// Summary description for Urls
/// </summary>
public static class Urls
{
    public static string GetHome()
    {
        return "/";
    }

    public static class Samples
    {
        private const string BasePath = "/samples/";

        public static string GetHome()
        {
            return BasePath;
        }

        public static string GetForm()
        {
            return BasePath + "form.aspx";
        }

        public static string GetList()
        {
            return BasePath + "list.aspx";
        }

        public static string GetTree()
        {
            return BasePath + "tree.aspx";
        }

        public static string GetPager()
        {
            return BasePath + "pager.aspx";
        }

        public static string GetLinkButton()
        {
            return BasePath + "linkButton.aspx";
        }

        public static string GetMessageBox()
        {
            return BasePath + "messageBox.aspx";
        }

        public static string GetTab(int tabIndex)
        {
            string url = BasePath + "tabs.aspx";
            if (tabIndex > 0)
                url += "/" + (tabIndex + 1);
            return url;
        }

        public static string GetHtmlEditor()
        {
            return BasePath + "htmlEditor.aspx";
        }

        public static string GetPostRedirectUrl(long threadID, long postID)
        {
            return "/~/post.aspx?thread=" + threadID + "&post=" + postID;
        }

        public static string GetDiscussion()
        {
            return GetDiscussion(0, 0);
        }

        public static string GetDiscussion(int pageIndex, long postID)
        {
            string url = "/company.aspx";

            if (pageIndex > 1)
                url += "/" + pageIndex;

            if (0 != postID)
                url += "#p" + postID;

            return url;
        }

        public static string GetCompanyDiscussion(long companyID, int pageIndex, long postID)
        {
            string url = "/company.aspx/" + companyID;

            if (pageIndex > 0)
                url += "/" + ++pageIndex;

            if (0 != postID)
                url += "#p" + postID;

            return url;
        }

        public static string GetSpecialUrls()
        {
            return BasePath + "misc/urls.aspx";
        }

        public static string GetBreadcrumbsAndActions()
        {
            return BasePath + "misc/crumbsActions.aspx";
        }

        public static string GetConditional()
        {
            return BasePath + "misc/conditional.aspx";
        }

        public static string GetQueryString(int dec, string message)
        {
            return BasePath + "misc/queryString.aspx?dec=" + dec + "&message=" + System.Web.HttpUtility.UrlEncode(message);
        }

        public static string GetPathInfo(int dec, int hex, int base64)
        {
            return BasePath + "misc/pathInfo.aspx/" + dec + "/" + hex.ToString("x") + "/" + ConvertUtility.ToString(base64, 64);
        }

        //public static string GetEditFormTabs()
        //{
        //    return "/editFormTabs.aspx";
        //}

        //public static string GetEditForm()
        //{
        //    return "/editForm.aspx";
        //}

        //public static string GetSubmissions()
        //{
        //    return "/submissions.aspx/all/0";
        //}

    }

    public static class Classifieds
    {
        public static string GetHome()
        {
            return "/";
        }

        public static string GetRoot()
        {
            return "root/";
        }

        public static string GetAdmin()
        {
            return "admin/";
        }

        public static  string GetAttribute(long categoryID, long attrID)
        {
            return GetHome() + GetRoot() + GetAdmin() + "attribute.aspx/" + categoryID + "/" + attrID+ "/"+ 0;
        }

        public static string GetCustomAttribute(long categoryID, long attrID)
        {
            return GetHome() + GetRoot() + GetAdmin() + "attribute.aspx/" + categoryID + "/" + attrID+ "/"+1;
        }

        public static string GetCategoryDelete(long categoryID)
        {
            return GetHome() + GetRoot() + GetAdmin() + "deleteConfirm.aspx/" + categoryID + "/0/0/" + (int)Helper.Entity.Category;
        }

        public static string GetAttributeDelete(long categoryID, long attrID)
        {
            return GetHome() + GetRoot() + GetAdmin() + "deleteConfirm.aspx/" + categoryID + "/" + attrID+ "/0/"+(int)Helper.Entity.Attribute;
        }

        public static string GetAttributeValueDelete(long categoryID, long attrID, short attributeValue)
        {
            return GetHome() + GetRoot() + GetAdmin() + "deleteConfirm.aspx/" + categoryID + "/" + attrID + "/"+ attributeValue+"/"+(int)Helper.Entity.AttributeValue;
        }

        public static string GetCategoryEdit(long categoryID)
        {
            return GetHome() + GetRoot() + GetAdmin() + "category.aspx/" + categoryID;
        }

        public static string GetCategoryEdit(long categoryID, long parentCategoryID)
        {
            return GetHome() + GetRoot() + GetAdmin() + "category.aspx/" + categoryID+"/"+parentCategoryID;
        }

        public static string GetCategoryInfo(long categoryID, int pageIndex)
        {
            return GetHome() + GetRoot() + "category.aspx/" + categoryID+"/"+pageIndex;
        }

        public static string GetCategoriesPageUrlPattern(long categoryID, bool isMiles, int? miles, string adType, bool isPictures, string sortMode, string categories)
        {
            return GetHome() + GetRoot() + "category.aspx/" + categoryID + "/{0}/" + Convert.ToInt32(isMiles) + "/" + (miles == null ? 0 : miles) + "/" + adType + "/" + Convert.ToInt32(isPictures) + "/" + sortMode + "/" + categories;
        }

        public static string GetCategoriesFirstPageUrlPattern(long categoryID, bool isMiles, int? miles, string adType, bool isPictures, string sortMode, string categories)
        {
            return GetHome() + GetRoot() + "category.aspx/" + categoryID + "/0/" + Convert.ToInt32(isMiles) + "/" + (miles == null ? 0 : miles) + "/" + adType + "/" + Convert.ToInt32(isPictures) + "/" + sortMode + "/" + categories;
        }

        public static string GetCategoryInfo(long categoryID)
        {
            return GetHome() + GetRoot() + "category.aspx/" + categoryID;
        }

        public static string GetInfoAd(long adID)
        {
            return GetHome() + GetRoot() + "infoAd.aspx/" + adID;
        }

        public static string GetEditAd(long adID)
        {
            return GetHome() + GetRoot() + "editAd.aspx/" + adID;
        }

        public static string GetAddNewAd(long adID, long categoryID)
        {
            return GetHome() + GetRoot() + "editAd.aspx/" + adID + "/" + categoryID;
        }

        public static string GetSelect(long fCategoryID, long sCategoryID)
        {
            return GetHome() + GetRoot() + "select.aspx/" + fCategoryID + "/" + sCategoryID;
        }

        public static string GetSelect(long fCategoryID)
        {
            return GetHome() + GetRoot() + "select.aspx/" + fCategoryID;
        }

        public static string GetAdRenew(long adID, int daysAdd)
        {
            return GetHome()+ GetRoot() +GetAdmin() + "confirm.aspx/" + adID+"/"+daysAdd+"/"+(byte)Helper.ActionType.Renew;
        }

        public static string GetAdAbuse(long adID)
        {
            return GetHome() + GetRoot() + "flag.aspx/" + adID;
        }

        public static string GetPostRedirectUrl(long threadID, long postID)
        {
            return GetHome()+GetRoot()+"/post.aspx?thread=" + threadID + "&post=" + postID;
        }

        public static string GetAdminDefault()
        {
            return GetHome() + GetRoot() + GetAdmin() + "adminDefault.aspx";
        }

        public static string GetMyAds(byte type, int status)
        {
            return GetHome() + GetRoot() + "myAds.aspx/" + type + "/" + status;
        }

        public static string GetAdsToApproveList(int pageIndex)
        {
            return GetHome() + GetRoot()+GetAdmin()+ "adsApproveList.aspx/"+pageIndex;
        }

        public static string GetAdApprove(long adID)
        {
            return GetHome() + GetRoot() + GetAdmin() + "adApprove.aspx/" + adID;
        }

        public static string GetSettings()
        {
            return GetHome() + GetRoot() + GetAdmin() + "settings.aspx";
        }

        public static string GetAdsDelete(long adID)
        {
            return GetHome() + GetRoot() + GetAdmin() + "confirm.aspx/" + adID+"/0/"+(byte)Helper.ActionType.Delete;
        }

        public static string GetAdDiscussion(long adID, int pageIndex, long postID)
        {
            string url = GetRoot()+"infoAd.aspx/" + adID;

            if (pageIndex > 0)
                url += "/" + ++pageIndex;

            if (0 != postID)
                url += "#p" + postID;

            return url;
        }
    }

}